Method WithParameters(params (string Name, IExpression Value)[])
Returns the same expression with named XPath variables bound to expressions, so a value from
the message can take part in the query without being pasted into its text.
public TypedXPathExpression<TValue> WithParameters(params (string Name, IExpression Value)[] parameters)
Remarks
XPath("/order[@id=$id]").WithParameters(("id", Header("orderId"))). The value is
passed to the engine as a value: it is compared, never parsed, so a header holding
B-2' or '1'='1 selects an order with that literal id and matches nothing, rather than
changing what the query asks.
The alternative is building the path by concatenation, which Camel offers as
allowSimple — and which is the reason XPath injection has a CodeQL query and an OWASP
entry of its own. Binding values instead is old and settled practice: JAXP's
XPathVariableResolver, XQuery's declare variable $x external, .NET's
XsltArgumentList, and prepared statements in SQL are all the same idea.
The path also stays one constant string whatever the data, which is what lets a compiled
expression be reused; concatenation defeats that by construction.
XPath only. jpath has no equivalent, and not because of the library: RFC 9535 has no
variables at all, so there is nothing for JsonPath.Net to expose.